from typing import *


class Solution:
    def minimumOperations(self, nums: List[int]) -> int:

        h, p = {}, -1
        for i, v in enumerate(nums):
            if v in h:
                p = max(p, h[v])
            h[v] = i
        return p // 3 + 1
